package com.rerun.phone.memberuser;

import com.rerun.common.anno.ResponseExceptionReturn;
import com.rerun.common.bean.Rest;
import com.rerun.common.controller.SuperController;
import com.rerun.entity.Evaluate;
import com.rerun.service.IEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 
 * @author jun
 *	求职者评论
 */
@Api(value = "求职者评论", description = "求职者评论")
@RestController
@RequestMapping("/memberApi/Evaluate")
public class EvaluateController extends SuperController{
	@Autowired
	private IEvaluateService evaluateService;
	
	@ApiOperation(value ="展示求职者对应的评论信息", notes ="展示求职者对应的评论信息", httpMethod = "GET")
	@RequestMapping(value="/showMemberEvaluate",method = RequestMethod.GET)
	@ResponseExceptionReturn
	public Rest showMemberEvaluate(String memberId){
		//展示该用户对应的评论 
	 Evaluate data = evaluateService.selectById(memberId);
		 if(data!=null){
			return Rest.okData(data);
		 }
		return Rest.ok("暂无评论");
		
	}
	@ApiOperation(value = "展示园所评论信息", notes = "展示园所对应的评论信息", httpMethod = "GET")
	@RequestMapping(value="/showParkEvaluate",method = RequestMethod.GET)
	@ResponseExceptionReturn
	public Rest showParkEvaluate(String parkId){
		//展示该用户对应的评论 
		Evaluate data = evaluateService.selectById(parkId);
		if(data!=null){
			return Rest.okData(data);
		}
		return Rest.ok("暂无评论");
		
	}

	@ApiOperation(value = "发评论", notes = "发评论信息", httpMethod = "POST")
	@RequestMapping(value="/AddEvaluate",method = RequestMethod.POST)
	@ResponseExceptionReturn
	public  Rest addMemberEvaluate(Evaluate evaluate){
		if(evaluate!=null){
			
			evaluate.setCreateTime(new Date());
			evaluateService.insert(evaluate);
			return Rest.ok();
		}
		return Rest.ok("暂无评论");
	}
}
